package com.hunttown.mes.dao;

import com.hunttown.common.dao.base.BaseDao;
import com.hunttown.common.domain.Query;
import com.hunttown.mes.domain.TransportTaskSub;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * created by wangjunfu on 2022-02-15 08:51:16
 */
@Repository
public class TransportTaskSubDao extends BaseDao {
    private static final Logger logger = LoggerFactory.getLogger(TransportTaskSubDao.class);

    public TransportTaskSub insert(final TransportTaskSub transportTaskSub) {
        insert("TransportTaskSub.insert", transportTaskSub);
        return transportTaskSub;
    }

    public Boolean updateInfoById(final TransportTaskSub transportTaskSub) {
        return update("TransportTaskSub.updateInfoById", transportTaskSub) > 0;
    }

    public Boolean updateInfoByQuery(final Query query) {
        return update("TransportTaskSub.updateInfoByQuery", query) > 0;
    }

    public TransportTaskSub selectById(final Integer id, final Integer entId) {
        Query query = Query.noPage();
        query.put("id", id);
        query.put("entId", entId);
        return queryForObject("TransportTaskSub.selectById", query);
    }

    public List<TransportTaskSub> selectByQuery(final Query query) {
        return queryForList("TransportTaskSub.selectByQuery", query);
    }

    public Long countByQuery(final Query query) {
        return queryForObject("TransportTaskSub.countByQuery", query);
    }

    public Boolean deleteById(final Integer id, final Integer entId) {
        TransportTaskSub transportTaskSub = new TransportTaskSub();
        transportTaskSub.setDeleteFlag(1);
        transportTaskSub.setId(id);
        transportTaskSub.setEntId(entId);

        return update("TransportTaskSub.updateInfoById", transportTaskSub) > 0;
    }

    //物理删除不可恢复，慎用！
    public Boolean deleteByIdForPhysical(final Integer id) {
        Query query = Query.noPage();
        query.put("id", id);
        return delete("TransportTaskSub.deleteById", query) > 0;
    }
}